<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/12/6
 * Time: 9:12
 */

namespace Admin\Controller;


class MessageController extends AdminController
{
     public function index(){
         $contact=M("contact");
         $message_data=$contact->order("`id` desc")->select();
         $this->assign("message_data",$message_data);
         //print_r($message_data);exit;
         $this->assign("meta_title","留言板");
         $this->display();
     }
    public function edit($id = 0){
        $id=I("get.id",0,"int");
        $message=M("contact");
        $data=$message->where("`id`=".$id)->find();
        $this->assign("data",$data);
        $this->display();

    }
    public function del($ids = 0){
        if(empty($ids)){
            $this->error('参数错误！');
        }
        if(is_array($ids)){
            $map['id'] = array('in', $ids);
        }elseif (is_numeric($ids)){
            $map['id'] = $ids;
        }
        if(M('contact')->where($map)->delete()){
            //记录行为
            
            $this->success('删除成功');
        } else {
            $this->error('删除失败！');
        }
    }
}